import jwt_decode from "jwt-decode";
import { TokenResult } from "./services/gadmin/typings";

/**
 * 保存 token
 * @param token
 */
export function saveToken(data: TokenResult) {
  localStorage.setItem("token", data.token)
}

/**
 * 获取 token
 */
export function getToken(): string {
  const token = localStorage.getItem("token")
  return token || ""
}

/**
 * 解析token
 */
export function getTokenData(): any {
  return jwt_decode(getToken())
}
